<template>
    <el-container>
        <el-header>
            <div class="left-panel">
                <el-button
                    type="primary"
                    plain
                    icon="el-icon-plus"
                    @click="opAdd"
                >新增</el-button>
               
            </div>
            <div class="right-panel">
                <el-button :icon="Search" type="primary" @click="opBindData">查询</el-button>
                <el-button :icon="Search" type="info" plain @click="resetSearch">重置</el-button>
                <el-button text type="primary" @click="showCondition = !showCondition">
                    <span v-if="!showCondition">展开</span>
                    <span v-else>收起</span>
                    <vab-icon
                        class="vab-dropdown"
                        :class="{ 'vab-dropdown-active': fold }"
                        icon="arrow-up-s-line"
                    />
                </el-button>
            </div>
        </el-header>
        <el-foot v-show="showCondition">
            <vab-query-form-top-panel>
                
                <el-form inline label-width="49px" :model="queryForm" style="margin-top: 5px">
                    
                </el-form>
            </vab-query-form-top-panel>
        </el-foot>

        <el-main class="nopadding">
                <scTable
                    ref="mytable"
                    :queryType="'systemConfig/pages'"
                    :data="listData"
                    :queryList="queryList"
                    :column="columnList"
                    :orderList="OrderList"
                    :sort-orders="['ascending', 'descending']"
                    @selection-change="selectionChange"
                    
                    stripe
                    border
                >
                   <el-table-column type="selection" width="50"></el-table-column>
                   <el-table-column label="序号" type="index" width="60" />
                   <el-table-column prop="systemCode" label="参数编码" width="150" sortable></el-table-column>
                   <el-table-column prop="systemName" label="参数名称" width="200" sortable></el-table-column>
                   <el-table-column prop="systemValue" label="参数名称" width="200" sortable></el-table-column>
                    
                    <el-table-column prop="status" label="状态"  width="150" sortable >
                        <template #default="scope">
                            <el-tag type="danger" effect="plain"  v-if="scope.row.status==0">禁用</el-tag>
                            <el-tag type="success" effect="plain" v-else-if="scope.row.status==1">正常</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column prop="remarks" label="备注" width="300" sortable></el-table-column>
                    <el-table-column prop="createTime" label="创建时间" width="200" sortable></el-table-column>
                    <el-table-column label="操作" fixed="right" align="right" width="200" >
                    <template #default="scope">
                        <el-button-group>
                            <el-button
                                text
                                type="primary"
                                size="small"
                                @click="opShow(scope.row, scope.$index)"
                            ><el-icon><View /></el-icon> 查看</el-button>
                            <el-button
                                text
                                type="primary"
                                size="small"
                                @click="opEdit(scope.row, scope.$index)"
                            ><el-icon><EditPen /></el-icon>编辑</el-button>
                            <el-popconfirm
                                title="确定删除吗？"
                                @confirm="opDelete(scope.row, scope.$index)"
                            >
                                <template #reference>
                                    <el-button
                                        text
                                        type="danger"
                                        size="small"
                                    ><el-icon><Delete /></el-icon>删除</el-button>
                                </template>
                            </el-popconfirm>
                        </el-button-group>
                        
                    </template>
                </el-table-column>
                </scTable>
            
        </el-main>
    </el-container>
    <save-dialog
        v-if="dialogSave"
        ref="saveDialog"
        @fatherMethod="opBindData"
        @success="handleSaveSuccess"
        @closed="dialogSave = false"
    ></save-dialog>
   
   
</template>

<script>

import publicjs from "@/api/model/publicjs";
import saveDialog from "./save";
import tool from "@/utils/tool";
export default {
    name: "systemConfig",
    components: {
        publicjs,
        saveDialog
    },
    data() {
        return {
            dialogSave: false,
            dialogDetail: false,
            //审核状态
            auditState: false,
            showCondition: false,
            selectionRows: [],
            pkList: [""],
            columnList: [],
            OrderList: { },
            queryList: {
              
            },
            result: "", // 运行结果
            props1: {
                checkStrictly: true,
                emitPath: false,
            },
           
            optionsLogSource: [],//消息来源
            optionsLogType: [],//消息分类
            optionsStatus:[],//消息状态
            orgType: 1,

           
        };
    },
    methods: {
         //添加
         opAdd() {
            this.dialogSave = true;
            this.$nextTick(() => {
                this.$refs.saveDialog.open("Add");
            });
        },
        //编辑
        opEdit(row) {
            this.dialogSave = true;
            this.$nextTick(() => {
                this.$refs.saveDialog.open("Edit").setData(row);
            });
        },
          //查看
          opShow(row) {
            this.dialogSave = true;
            this.$nextTick(() => {
                this.$refs.saveDialog.open("Show").setData(row);
            });
        },
         //删除
         async opDelete(row) {
            try {
                var returnValue = await this.$API.auth.PostProcessApi.post(
                    "systemConfig/delete",
                    { Id: row.id }
                );
                if (returnValue.status == 200) {
                    this.$message.success("操作成功");
                    this.$refs.mytable.getData();
                } else {
                    this.$message.error("操作失败:" + returnValue.msg);
                }
            } catch (error) {
                this.loading = false;
                return false;
            }
        },
         //表格选择后回调事件
         selectionChange(selection) {
            this.selectionRows = selection;
            console.log("选择",selection);
        },
        //本地更新数据
        handleSaveSuccess(data, mode) {
            if (mode == "Add") {
                this.$refs.mytable.refresh();
            } else if (mode == "Edit") {
                this.$refs.mytable.refresh();
            }
        },
        async opBindData() {
            this.$refs.mytable.clearSort();
            this.$refs.mytable.getData();
        },
        resetSearch() {
            this.queryList = {};
        },
       
       
    },
    async mounted() {
        await this.opBindData();
    },
};
</script>
<style>
.dot-flash {
  width: 15px;
  height: 15px;
  background-color: #13ce66; /* 绿色 */
  border-radius: 50%; /* 圆形 */
  animation: blinker 2s linear infinite;
}
 
.dot-flash-out
{
  width: 15px;
  height: 15px;
  background-color: #ce1313; /* 绿色 */
  border-radius: 50%; /* 圆形 */
}
@keyframes blinker {
  50% {
    opacity: 0;
  }
}
</style>